﻿using Domain.Models;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;

namespace Infrastructure.IService
{
    public interface IRepository<T> where T : BaseEntity
    {
        Task<T> SingleOrDefaultAsync(Expression<Func<T, bool>> predicate = null, CancellationToken cancellationToken = default);
        Task<T> FirstOrDefaultAsync(Expression<Func<T, bool>> predicate = null, CancellationToken cancellationToken = default);
        Task<IReadOnlyCollection<T>> ToListAsync(Expression<Func<T, bool>> predicate = null, CancellationToken cancellationToken = default);
        Task<IReadOnlyCollection<T>> ToListPageAsync(Expression<Func<T, bool>> predicate = null, int size = 10, int index = 1, CancellationToken cancellationToken = default);
        Task<T> AddAsync(T entity, CancellationToken cancellationToken = default);
        Task RemoveAsync(T entity, CancellationToken cancellationToken = default);
        Task ModifyAsync(T entity, CancellationToken cancellationToken = default);
    }
}
